package design_pattern.Singleton;

/**
 * @Author: 蔡翔
 * @Date: 2019/10/23 15:47
 * @Version 1.0
 * 最好的方式就是 枚举方式
 */
public class SingletonObject6 {
    private SingletonObject6(){

    }
    private enum Singleton{
        INSTANCE;
        private final SingletonObject6 instance;

        // 这里实例化Singleton 默认就是INSTANCE;
        Singleton(){
            instance = new SingletonObject6();
        }
        public SingletonObject6 getInstance(){
            return instance;
        }
    }
    public static SingletonObject6 getInstance(){
        return Singleton.INSTANCE.getInstance();
    }

}
